<include file="Public/head" />
<style type="text/css">
    .marks .marks-l{width:15%;height:100%;float:left;}
    .marks .marks-r{width:82%;height:100%;float:left;}
    .marks .marks-r span{width:100px;height:32px;line-height:32px;margin-left:20px;color:#333333;
                         background-color:#ccc;border: 1px solid #999999; float:left;display:block;}
    .tijiao-marks{margin-top: 30px;}
    .tijiao-marks input{
        background: #20ab4f none repeat scroll 0 0;border: 1px solid #20ab4f;border-radius: 3px;color: #fff;
        cursor: pointer;font-size: 14px; height: 30px;line-height: 30px;margin: 30px 10px;text-align: center;width: 170px;}
    .car_info{margin:10px 20px;}
    .car_info .car_no{width:100%;height:36px;margin-bottom:10px;}
    .car_info .car_no span{width:150px;height:36px;line-height:36px;display:block;float:left;background-color:#20ab4f;border:1px solid #FFF;color:#fff;text-align:center;border-radius:5px}
    .car_info table tr td{height:30px;text-align:left;font-size:12px;padding-left:10px;}
    .xuanzhe1 input{border: 1px solid #c8c8c8;height: 22px;line-height: 22px;
                    padding-right: 30px;text-align: center;width: 165px;}
    .xuanzhe1 em{position: absolute;right: 20px;top: 0;}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="cyxs.xs" />

    <div class="mianR">
        <h3 class="cha">车辆下架</h3>
        <div class='car_info'>
            <div class='car_no'><span>车辆编号：{$list.car_no}</span></div>
            <div class='clear'></div>
            <table border='1' width='80%'>
                <tbody>
                    <tr>
                        <td colspan='4'><span  style='color:#20ab4f'>车辆信息</span></td>
                    </tr>
                    <tr>
                        <td>车型</td>
                        <td>{$list.car_model}</td>
                        <td>排放标准</td>
                        <td>{$list.emission}</td>
                    </tr>
                    <tr>
                        <td>初登日期</td>
                        <td>{$list.first_reg_date}</td>
                        <td>颜色</td>
                        <td>{$list.car_color}</td>
                    </tr>
                    <tr>
                        <td>表显里程（万公里）</td>
                        <td>{$list.pointer_mileage}</td>
                        <td>车况级别</td>
                        <td>{$list.chek_level}</td>
                    </tr>
                    <tr>
                        <td>车辆注册地</td>
                        <td>{$list.first_reg_city}</td>
                        <td>车牌号</td>
                        <td>{$list.chepai_hao}</td>
                    </tr>
                    <tr>
                        <td>车架号</td>
                        <td>{$list.vin}</td>
                        <td>销售价</td>
                        <td>{$list.reserve_price}</td>
                    </tr>
                </tbody>
            </table>
            <table border='1' width='80%' style='margin-top:20px;'>
                <tbody>
                    <tr>
                        <td colspan='4'><span style='color:#20ab4f'>车主信息</span></td>
                    </tr>
                    <tr>
                        <td>车主类型</td>
                        <td>{$list.owner_type_name}</td>
                        <if condition="$list.owner_type eq 1">
                            <td>车主姓名</td>
                            <td>{$list.seller_name}</td>
                            <else />
                            <td>公司名称</td>
                            <td>{$list.seller_name}</td>
                        </if>
                        <if condition="$list.owner_type eq 1">
                            <td>联系电话</td>
                            <td>{$list.phone}</td>
                            <else />
                            <td>联系人姓名</td>
                            <td>{$list.contact_person}</td>
                            <td>联系电话</td>
                            <td>{$list.phone}</td>
                        </if>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="marks">
            <h2>请选择下架结果：</h2>
            <!--            <div class='tab'>   
                            <li class='current'>销售成功</li>
                            <li>销售失败</li>
                        </div>-->
            <div class="yuyue">
                <ul>
                    <li class="yuCurrent">销售成功</li>
                    <li>销售失败</li>
                    <li>重回上架</li>
                </ul>
            </div>
            <div class="listBox">

                <div class="yuList" >
                    <div class="xuanzhe1" >
                        <ul>
                            <form name=myform>
                                <li class="reason clearfix chengjiao">
                                    <span>成交价格</span>
                                    <input id="success_price" type="text" value="" name="success_price"  placeholder='请输入成交价格'>
                                    <!--                                    <em>元</em>-->
                                </li>
                                <li class="reason clearfix">
                                    <span>备注</span>
                                    <textarea name="success_remark" cols="50"
                                              onKeyDown="textCounter(this.form.message, this.form.remLen, 50);"
                                              onKeyUp="textCounter(this.form.message, this.form.remLen, 50);"></textarea>
                                    <em>请输入不卖的原因字数限制在25字以内</em>
                                </li>
                            </form>
                        </ul>
                        <div class="yongBtn">
                            <input type="button" value="确定" class="queding" name='success_submit'/>
                            <input name="success_reset" type="reset" class="quxiao" value="取消" />
                        </div>
                    </div>
                </div>

                <div class="yuList" style='display:none'>
                    <div class="xuanzhe1" >
                        <ul>
                            <li class="genBtn1 clearfix trace">
                                <input type="hidden" id="trace_reason" value="">
                                <span class="gencuur">车主已出售<input name="trace_reason" value="车主已出售" type="checkbox"/></span>
                                <span class="gencuur">车主不卖了<input name="trace_reason" value="车主不卖了" type="checkbox"/></span>
                            </li>
                            <li class="reason clearfix"><span>其他原因</span><textarea name="trace_other_reason"></textarea></li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding" name="fail_submit"/>
                        <input name="fail_reset" type="reset" class="quxiao" value="取消" />
                    </div>
                </div>
                <!--重新回到待上拍状态-->
                <div class="yuList" style='display:none'>
                    <!--<div class="xuanzhe1" ></div>-->
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding" name="back_submit"/>
                        <input name="back_reset" type="reset" class="quxiao" value="取消"/>
                    </div>
                </div>

            </div>

        </div>
    </div>
    <div class="clear"></div>
    <script type="text/javascript">
        // 回到待拍卖状态
        $("input[name='back_submit']").on('click',function(){
              var back_params = {
                  'sale_id':{$sale_id}
              }
             $.post("{:U('CarShow/back_up')}", back_params, function (res) {
                if (res.code == 200) {
                        btn_alert(res.msg);
                        setTimeout(function () {
                        window.location.href = "{:U('CarShow/index')}"+'?car_status='+{$list.car_status}+"&p="+{$p};
                    }, 2000);
                    } else {
                        shibai_alert(res.msg);
                    }
                }, 'json');
            });
        $("input[name='back_reset']").on("click", function () {
            setTimeout(function () {
                window.location.href = "{:U('CarShow/index')}"+'?car_status='+{$list.car_status}+"&p="+{$p};
            }, 500);
        });
        $("input[name='success_reset']").on("click", function(){
            $("input[name='success_price']").val("");
            $("textarea[name='success_remark']").val("");
        });
        $("input[name='fail_reset']").on("click", function(){
            $('textarea[name=trace_other_reason]').val("");
        });
        $("input[name='success_submit']").on('click', function(){
            var reg = /^[0-9]*[1-9][0-9]*$/; 　　
                var success_price = $("input[name='success_price']").val();
                var success_remark = $("textarea[name='success_remark']").val();
                if (success_price == ''){
                    shibai_alert("成交价格不能为空");
                    return false;
                }
        if (!reg.test(success_price)){
                shibai_alert("成交价格格式不正确");
                return false;
        }
        var success_params = {
                'type': 1,
                'sale_id':{$sale_id},
                'success_price':success_price,
                'success_remark':success_remark
        }
        $.post("{:U('CarShow/down_post')}", success_params, function (res) {
            if (res.code == 200) {
                    shibai_alert(res.msg);
                    setTimeout(function () {
                    window.location.href = "{:U('CarShow/index')}"+'?car_status='+{$list.car_status}+"&p="+{$p};
                }, 2000);
            } else {
                shibai_alert(res.msg);
            }
            }, 'json');
        });
        $("input[name='success_reset']").on("click", function () {
            setTimeout(function () {
                window.location.href = "{:U('CarShow/index')}"+'?car_status='+{$list.car_status}+"&p="+{$p};
            }, 500);
        });
        
        $("input[name='fail_submit']").on('click', function(){
            var trace_reason_selected = $("input[name='trace_reason']:checked").val();
            var trace_reason_other = $.trim($('textarea[name=trace_other_reason]').val());
            var trace_reason = trace_reason_selected ? trace_reason_selected : trace_reason_other;
            if (trace_reason == ''){
                shibai_alert("失败原因不能为空");
                return false;
            }   
            var fail_params = {
                    'type': 2,
                    'sale_id':{$sale_id},
                    'fail_reason':trace_reason
            }
            $.post("{:U('CarShow/down_post')}", fail_params, function (res) {
                if (res.code == 200) {
                        shibai_alert(res.msg);
                        setTimeout(function () {
                            window.location.href = "{:U('CarShow/index')}"+'?car_status='+{$list.car_status}+"&p="+{$p};
                        }, 2000);
                } else {
                    shibai_alert(res.msg);
                }
            }, 'json');
//                var success_price = $("input[name='success_price']").val();
//                var success_remark = $("input[name='success_remark']").val();
//                var success_params = {
//                        'success_price':success_price,
//                        'success_remark':success_remark
//                }
//                $.post("{:U('CarShow/down_post')}", success_params, function (res) {
//                    if (res.code == 200) {
//                        setTimeout(function () {
//                            window.location.href = "{:U('CarShow/index')}";
//                        }, 2000);
//                    } else {
//                        shibai_alert(res.msg);
//                    }
//                }, 'json');
        });
        $("input[name='fail_reset']").on("click", function () {
            setTimeout(function () {
                window.location.href = "{:U('CarShow/index')}"+'?car_status='+{$list.car_status}+"&p="+{$p};
            }, 500);
        });
        //            var param = {
        //                "sale_id": {$sale_id},
        //                "car_marks": sel_str
        //            }
        //            $.post("{:U('CarShow/up_post')}", param, function (res) {
        //                if (res.code == 200) {
        //                    setTimeout(function () {
        //                        window.location.href = "{:U('CarShow/index')}";
        //                    }, 2000);
        //                } else {
        //                    shibai_alert(res.msg);
        //                }
        //            }, 'json');
    </script>
    <include file="Public/foot" />
